package com.js.rtu.config;

import com.js.rtu.RTUApplication;
import com.js.rtu.util.ConfigMgr;

import java.util.List;

/**
 * ini配置
 * Created by wz on 2020/12/1.
 */
public class IniConfig {

    public static List<String> workType_data;//工作模式-代号
    public static List<String> workType_des;//工作模式-描述

    public static List<String> moNiLiangBiao_data;//模拟量表类型-代号
    public static List<String> moNiLiangBiao_des;//模拟量表类型-描述

    public static List<String> power_data;//电压列表-电压值
    public static List<String> power_des;//电压列表-电压
    public static List<String> power_settings;//电压列表-电压设置值

    public static List<String> zibaojiange_data;//存储自报间隔-时间值
    public static List<String> zibaojiange_des;//存储自报间隔-描述


    public static List<String> agreement_data;//流量计类型-流量计型号，通讯协议

    public static List<String> baudRate_data;//波特率-代号
    public static List<String> baudRate_des;//波特率-描述

    public static List<String> dataBit_data;//数据位-代号
    public static List<String> dataBit_des;//数据位-描述

    public static List<String> checkBit_data;//校验位-代号
    public static List<String> checkBit_des;//校验位-描述

    public static List<String> stopBit_data;//停止位-代号
    public static List<String> stopBit_des;//停止位-描述

    public static List<String> connectType_data;//连接类型-代号
    public static List<String> connectType_des;//连接类型-描述


    public static List<String> fenduanzibaojiange_data;//分段自报间隔-时间值
    public static List<String> fenduanzibaojiange_des;//分段自报间隔-描述

    public static List<String> alarm_data;//报警类型-代号
    public static List<String> alarm_des;//报警类型-描述


    static {
        RTUApplication localBaseApp = RTUApplication.getInstance();
        workType_data= ConfigMgr.getInstance(localBaseApp).readProperties("工作模式", "代号");
        workType_des= ConfigMgr.getInstance(localBaseApp).readProperties("工作模式", "描述");



        moNiLiangBiao_data= ConfigMgr.getInstance(localBaseApp).readProperties("模拟量表类型", "代号");
        moNiLiangBiao_des= ConfigMgr.getInstance(localBaseApp).readProperties("模拟量表类型", "描述");

        power_data= ConfigMgr.getInstance(localBaseApp).readProperties("电压列表", "电压值");
        power_des= ConfigMgr.getInstance(localBaseApp).readProperties("电压列表", "电压");
        power_settings= ConfigMgr.getInstance(localBaseApp).readProperties("电压列表", "电压设置值");

        zibaojiange_data= ConfigMgr.getInstance(localBaseApp).readProperties("存储自报间隔", "时间值");
        zibaojiange_des= ConfigMgr.getInstance(localBaseApp).readProperties("存储自报间隔", "描述");



        agreement_data= ConfigMgr.getInstance(localBaseApp).readProperties("流量计类型", "流量计型号");



        baudRate_data= ConfigMgr.getInstance(localBaseApp).readProperties("波特率", "代号");
        baudRate_des= ConfigMgr.getInstance(localBaseApp).readProperties("波特率", "描述");


        dataBit_data= ConfigMgr.getInstance(localBaseApp).readProperties("数据位", "代号");
        dataBit_des= ConfigMgr.getInstance(localBaseApp).readProperties("数据位", "描述");

        checkBit_data= ConfigMgr.getInstance(localBaseApp).readProperties("校验位", "代号");
        checkBit_des= ConfigMgr.getInstance(localBaseApp).readProperties("校验位", "描述");

        stopBit_data= ConfigMgr.getInstance(localBaseApp).readProperties("停止位", "代号");
        stopBit_des= ConfigMgr.getInstance(localBaseApp).readProperties("停止位", "描述");


        connectType_data= ConfigMgr.getInstance(localBaseApp).readProperties("连接类型", "代号");
        connectType_des= ConfigMgr.getInstance(localBaseApp).readProperties("连接类型", "描述");

        fenduanzibaojiange_data= ConfigMgr.getInstance(localBaseApp).readProperties("分段自报间隔", "时间值");
        fenduanzibaojiange_des= ConfigMgr.getInstance(localBaseApp).readProperties("分段自报间隔", "描述");



        alarm_data= ConfigMgr.getInstance(localBaseApp).readProperties("报警类型", "代号");
        alarm_des= ConfigMgr.getInstance(localBaseApp).readProperties("报警类型", "描述");


    }

    /**
     * 从data-->des
     * @param msg
     * @param des 描述
     * @param data 数据
     * @return
     */
    public static String getDes(String msg, List<String> des , List<String> data){
        for (int i = 0; i < data.size(); i++) {
            if (data.get(i).equals(msg)) {
                return des.get(i);
            }
        }
        return "";
    }
    /**
     * 从des-->data
     * @param msg
     * @param des 描述
     * @param data 数据
     * @return
     */
    public static String getD(String msg, List<String> des , List<String> data){
        for (int i = 0; i < des.size(); i++) {
            if (des.get(i).equals(msg)) {
                return data.get(i);
            }
        }
        return "";
    }

}
